/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.allscore.nacos.consumer.restTemple;

import com.allscore.nacos.consumer.api.User;
import com.allscore.nacos.consumer.config.NacosConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class DemoNacosDiscoveryRestTemple {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private NacosConfig nacosConfig;

    private final static String BASE_URL = "http://demo-nacos-discovery";

    public User getUser() {
        String userPath = "/getUser";
        String url = nacosConfig.getUserUrl() + userPath;
        ResponseEntity<User> entity = restTemplate.postForEntity(url, null, User.class);
        User u = entity.getBody();
        return u;
    }

}
